data("rest_inspec")
rest_inspection =
rest_inspec %>%
count(boro,cuisine_description, grade) %>%
drop_na()
Column
Chart A
x <- list(
title = "cuisine"
)
y <- list(
title = "number of grade A restaurant"
)
rest_inspection %>%
filter(grade == "A", n >= 1000) %>%
group_by(cuisine_description, grade) %>%
mutate(count = sum(n),
cuisine_description = replace(cuisine_description, cuisine_description == "Latin (Cuban, Dominican, Puerto Rican, South & Central American)", "Latin" )) %>%
distinct(cuisine_description, grade, count) %>%
mutate(cuisine_description = fct_reorder(cuisine_description, count)) %>%
plot_ly( x = ~cuisine_description, y = ~count, color = ~cuisine_description,
type = "bar", colors = "viridis") %>%
layout(xaxis = x, yaxis = y)
## Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
## Please use `arrange()` instead.
## See vignette('programming') for more help
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_warnings()` to see where this warning was generated.
Column
Chart B
rest_inspection %>%
filter(cuisine_description == "Café/Coffee/Tea",
grade!="Not Yet Graded") %>%
plot_ly(x = ~grade, y = ~n, color = ~boro,type = "scatter", mode = "lines")
Chart C
rest_inspec %>%
select(score, boro) %>%
drop_na() %>%
subset(boro!="Missing") %>%
filter(score <= 60) %>%
mutate(boro = fct_reorder(boro, score)) %>%
plot_ly(x = ~boro, y = ~score, color = ~boro, colors = "viridis", type = "box")